/* GUI CONVERTED from ecincpro.p (converter v1.76) Sun Aug 25 22:15:31 2002 */
/* ecincpro.p - PCC INCORPORATION PROCESSOR                                   */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.10.1.9 $                                                      */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 7.4      LAST EDIT: 10/15/93   MODIFIED BY: pma *H013*           */
/* REVISION: 7.4      LAST EDIT: 10/27/94   MODIFIED BY: ame *H578*           */
/* REVISION: 8.6      LAST EDIT: 06/15/96   MODIFIED BY: Mariya Kutwal *K00C**/
/* REVISION: 8.6      LAST EDIT: 01/10/97   MODIFIED BY: *H0R5* Russ Witt     */
/* REVISION: 8.6      LAST EDIT: 04/17/97   MODIFIED BY: Joe Gawel     *K0BX**/
/* REVISION: 8.6      LAST EDIT: 07/07/97   MODIFIED BY: *K0G3* Russ Witt     */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98  BY: *L007* A. Rahane           */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98  BY: *K1Q4* Alfred Tan          */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98  BY: *J314* Alfred Tan          */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00  BY: *N08T* Annasaheb Rahane    */
/* REVISION: 9.1      LAST MODIFIED: 05/11/00  BY: *K260* Sathish Kumar       */
/* REVISION: 9.1      LAST MODIFIED: 08/14/00  BY: *N0KW* Jacolyn Neder       */
/* REVISION: 9.1      LAST MODIFIED: 08/23/00  BY: *N0MZ* Mudit Mehta         */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.10.1.7   BY: Jean Miller        DATE: 12/14/01  ECO: *P03Q*  */
/* $Revision: 1.10.1.9 $  BY: Subramanian Iyer      DATE: 08/05/02   ECO: *N1QL*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}

define variable beg_yn      like mfc_logical label "Begin Incorporation"
                                                      initial yes no-undo.
define variable nbr         like ecm_nbr     label "PCO Nbr"      no-undo.
define variable ecmid       like wo_lot      label "ID"           no-undo.
define variable dbase       like si_db                            no-undo.
define variable dte_out as date                                   no-undo.
define variable dec_out as integer                                no-undo.
define variable err_msg     like msg_nbr                          no-undo.
define variable msg as character label "Message" format "x(58)"   no-undo.
define variable prt_page    like mfc_logical                      no-undo.
define variable sv-comp     like ecd1_comp                        no-undo.
define variable sv-op       like ecd2_op                          no-undo.
define variable sv-sequence like ecd4_sequence                    no-undo.

define buffer psmstr for ps_mstr.
define buffer rodet  for ro_det.
define buffer ipddet for ipd_det.
define buffer inmstr for in_mstr.

define buffer ecm2 for ecm_mstr.

define new shared variable new_site like si_site.
define new shared stream prt.

define temp-table wk-table
   field wk-par like ecd1_par
   index wk-par is primary wk-par ascending.

/* DISPLAY TITLE */

/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
beg_yn   colon 40
with frame a width 80 side-labels attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

repeat:
   update beg_yn with frame a.

   bcdparm = "".
   {mfquoter.i beg_yn  }

   if not beg_yn
   then do:
      pause 2 no-message.
      undo, retry.
   end. /* IF NOT beg_yn */

   {mfselbpr.i "printer" 132 " " "stream prt"}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.

   {mfphead.i "stream prt" "(prt)"}

   /* P/S ITEMS TO BE UNDONE OR REDONE */
   FORM /*GUI*/ 
      nbr
      ecmid
      dbase
      ecm_title
      ecm_eff_date
      msg
      with STREAM-IO /*GUI*/  frame b width 132 down.

   /* SET EXTERNAL LABELS */
   setFrameLabels(frame b:handle).

   prt_page = no.

   mainloop:
   for each ecm_mstr
      fields(ecm_eff_date ecm_nbr ecm_selected_eff ecm_title)
      no-lock
      where ecm_eff_date <> ?
      and ecm_selected_eff <> ?
      by ecm_eff_date descending transaction
      with frame b width 132:

      
/*GUI*/ {mfguichk.i  &warn=false &stream="(prt)"} /*Replace mfrpchk*/


      if not prt_page
      then
         prt_page = yes.

      /* BEGIN UNINCORPORATION */
      {pxmsg.i &MSGNUM=3727 &ERRORLEVEL=1 &MSGBUFFER=msg}

      display stream prt
         space(5)
         substring(ecm_nbr,1,8)  @ nbr
         substring(ecm_nbr,9,8)  @ ecmid
         substring(ecm_nbr,17,8) @ dbase
         ecm_title
         ecm_eff_date
         msg
         with frame b STREAM-IO /*GUI*/ .

      down stream prt with frame b.
      err_msg = 0.

      begin-changes:
      do on error undo begin-changes, leave begin-changes:
         /* START PROCESSING ECD1_DET FOR PRODUCT STRUCTURE UNDO  */
         for each wk-table
            exclusive-lock:
            delete wk-table.
         end. /* FOR EACH wk-table */

         /* UNDO PRODUCT STRUCTURE RECORDS */
         ecd1-loop1:
         for each ecd1_det
            fields(ecd1_comp ecd1_nbr ecd1_par ecd1_ref)
            no-lock
            where ecd1_nbr = ecm_nbr
            break by ecd1_nbr by ecd1_par
            with frame b:

            assign
               err_msg = 1
               sv-comp = ecd1_comp.

            
/*GUI*/ {mfguichk.i  &warn=false &stream="(prt)"} /*Replace mfrpchk*/


            if first-of(ecd1_par)
            then do with frame b:
               {pxmsg.i &MSGNUM=3728 &ERRORLEVEL=1 &MSGBUFFER=msg
                        &MSGARG1=ecd1_par}
               display stream prt
                  msg
                  with frame b STREAM-IO /*GUI*/ .
               down stream prt with frame b.
            end.  /* IF FIRST-OF(ecd1_nbr) */

            /* DELETE ADDED PS_MSTR */
            for each ps_mstr
               exclusive-lock
               where ps_par  = ecd1_par
               and   ps_comp = ecd1_comp
               and   ps_ref  = ecd1_ref
               and right-trim(ps_start_ecn) = right-trim(ecm_nbr):
               delete ps_mstr.
            end. /* FOR EACH ps_mstr... */

            /* RESET END DATE ON ORIGINAL RECORD */
            for each ps_mstr
               exclusive-lock
               where ps_par     = ecd1_par
               and   ps_comp    = ecd1_comp
               and   ps_ref     = ecd1_ref
               and   ps_end_ecn = ecm_nbr
               by ps_start descending:

               for first psmstr
                  fields(ps_comp ps_par ps_end ps_end_ecn ps_mod_date ps_ref
                         ps_start ps_start_ecn ps_userid)
                  where psmstr.ps_par   = ps_mstr.ps_par
                  and   psmstr.ps_comp  = ps_mstr.ps_comp
                  and   psmstr.ps_ref   = ps_mstr.ps_ref
                  and  (psmstr.ps_start > ps_mstr.ps_start
                  and   psmstr.ps_start <> ?)
                  no-lock:
               end. /* FOR FIRST psmstr */

               if available psmstr
               then
                  ps_mstr.ps_end = psmstr.ps_start - 1.
               else
                  ps_mstr.ps_end = ?.

               find first psmstr
                  where psmstr.ps_par   = ps_mstr.ps_par
                  and   psmstr.ps_comp  = ps_mstr.ps_comp
                  and   psmstr.ps_ref   = ps_mstr.ps_ref
                  and  (psmstr.ps_start < ps_mstr.ps_start
                  or    psmstr.ps_start = ?)
                  exclusive-lock
                  no-error.

               if available psmstr
               and (psmstr.ps_end = ? or psmstr.ps_end >= ps_mstr.ps_start)
               then do:
                  assign
                     psmstr.ps_end = ps_mstr.ps_start - 1
                     psmstr.ps_mod_date = today.
                  if batchrun
                  then
                     psmstr.ps_userid = report_userid.
                  else
                     psmstr.ps_userid = global_userid.
               end.  /* IF AVAILABLE psmstr... */

               assign
                  ps_mstr.ps_end_ecn  = ""
                  ps_mstr.ps_mod_date = today.

               if batchrun
               then
                  ps_mstr.ps_userid = report_userid.
               else
                  ps_mstr.ps_userid = global_userid.

            end.   /* FOR EACH ps_mstr.... */

            err_msg = 0.

            /* SAVE PARENT ITEM# IN TEMP TABLE FOR USE AT END OF PROGRAM */
            if last-of(ecd1_par)
            then do:

               for first wk-table
                  where wk-par = ecd1_par
                  no-lock:
               end. /* FOR FIRST wk-table */
               if not available wk-table
               then do:
                  create wk-table.
                  wk-par = ecd1_par.
               end.  /* IF NOT AVAILABLE WK-TABLE.... */

               /* PRODUCT STRUCTURE UNDO COMPLETE. PARENT # */
               {pxmsg.i &MSGNUM=3729 &ERRORLEVEL=1 &MSGBUFFER=msg
                        &MSGARG1=ecd1_par}

               display stream prt
                  msg
                  with frame b STREAM-IO /*GUI*/ .

               down stream prt
                  with frame b.
            end.  /* IF LAST-OF(ecd1_par) AND err_msg <> 0... */
         end. /* FOR EACH ecd1_det */

         if err_msg <> 0
         then
            undo begin-changes, leave begin-changes.

         /* UNDO ROUTING RECORDS */
         ecd2-loop:
         for each ecd2_det
            fields(ecd2_nbr ecd2_op ecd2_routing)
            no-lock
            where ecd2_nbr = ecm_nbr
            break by ecd2_nbr by ecd2_routing with frame b:

            assign
               err_msg = 1
               sv-op   = ecd2_op.

            
/*GUI*/ {mfguichk.i  &warn=false &stream="(prt)"} /*Replace mfrpchk*/


            /* PRINT 'ROUTING START' MESSAGE IF FIRST OF ROUTING   */
            if first-of(ecd2_routing)
            then do
               with frame b:
               /* START UNDO FOR ROUTING # */
               {pxmsg.i &MSGNUM=3730 &ERRORLEVEL=1 &MSGBUFFER=msg
                        &MSGARG1=ecd2_routing}
               display stream prt
                  msg
                  with frame b STREAM-IO /*GUI*/ .
               down stream prt with frame b.
            end.   /* IF FIRST(ecd2_nbr)... */

            /* DELETE ADDED RO_DET */
            for each ro_det
               exclusive-lock
               where ro_routing   = ecd2_routing
               and   ro_op        = ecd2_op
               and   ro_start_ecn = ecm_nbr:
               delete ro_det.
            end.   /* FOR EACH ro_det... */
            /* RESET END DATE ON ORIGINAL RECORD */
            for each ro_det
               exclusive-lock
               where ro_routing   = ecd2_routing
               and   ro_op        = ecd2_op
               and   ro_end_ecn   = ecm_nbr
               by ro_start descending:

               for first rodet
                  fields(ro_end ro_end_ecn ro_mod_date
                         ro_mod_userid ro_op ro_routing
                         ro_start ro_start_ecn)
                  where rodet.ro_routing = ro_det.ro_routing
                  and   rodet.ro_op      = ro_det.ro_op
                  and  (rodet.ro_start   > ro_det.ro_start
                  and   rodet.ro_start   <> ?)
                  no-lock:
               end. /* FOR FIRST rodet */

               if available rodet
               then
                  ro_det.ro_end = rodet.ro_start - 1.
               else
                  ro_det.ro_end = ?.

               find first rodet
                  where rodet.ro_routing = ro_det.ro_routing
                  and rodet.ro_op = ro_det.ro_op
                  and (rodet.ro_start < ro_det.ro_start
                  or rodet.ro_start = ?)
                  exclusive-lock
                  no-error.

               if available rodet
               and (rodet.ro_end = ? or rodet.ro_end >= ro_det.ro_start)
               then do:
                  assign
                     rodet.ro_end = ro_det.ro_start - 1
                     rodet.ro_mod_date = today.
                  if batchrun
                  then
                     rodet.ro_mod_userid = report_userid.
                  else
                     rodet.ro_mod_userid = global_userid.
               end.   /* IF AVAILABLE rodet... */

               assign
                  ro_det.ro_end_ecn = ""
                  ro_det.ro_mod_date = today.

               if batchrun
               then
                  ro_det.ro_mod_userid = report_userid.
               else
                  ro_det.ro_mod_userid = global_userid.

            end.   /* FOR EACH ro_det.... */

            err_msg = 0.

            if last-of(ecd2_routing)
            then do:
               /* ROUTING UNDO COMPLETE # */
               {pxmsg.i &MSGNUM=3731 &ERRORLEVEL=1 &MSGBUFFER=msg
                        &MSGARG1=ecd2_routing}
               display stream prt
                  msg
                  with frame b STREAM-IO /*GUI*/ .
               down stream prt with frame b.
            end.  /* LAST-OF(ecd2_routing)...  */
         end. /* FOR EACH ecd2_det */

         /* IF ERROR DETECTED IN ECD2_LOOP, ISSUE MESSAGE AND BYPASS */
         if err_msg <> 0
         then
            undo begin-changes, leave begin-changes.

         /* UNDO ITEM SPECIFICATION RECORDS */
         ecd4-loop:
         for each ecd4_det
            fields(ecd4_specid ecd4_nbr ecd4_op ecd4_part
                   ecd4_routing ecd4_sequence)
            no-lock
            where ecd4_nbr = ecm_nbr
            use-index ecd4_nbr_specid
            break by ecd4_nbr by ecd4_part by ecd4_routing
            by ecd4_op by ecd4_sequence with frame b:

            assign
               err_msg = 1
               sv-op = ecd4_op
               sv-sequence = ecd4_sequence.

            
/*GUI*/ {mfguichk.i  &warn=false &stream="(prt)"} /*Replace mfrpchk*/


            /* PRINT 'ITEM SPEC XXX START' MESSAGE IF FIRST ECD4_DET  */
            if first-of(ecd4_routing)
            then do with frame b:
               /* START UNDO OF ITEM SPECIFICATION.  ITEM # ROUTING # */
               {pxmsg.i &MSGNUM=3733 &ERRORLEVEL=1 &MSGBUFFER=msg
                        &MSGARG1=ecd4_part
                        &MSGARG2=ecd4_routing}
               display stream prt
                  msg
                  with frame b STREAM-IO /*GUI*/ .
               down stream prt with frame b.
            end.   /* IF FIRST-OF(ecd4_nbr)... */

            /* DELETE ADDED IPD_DETS */
            for each ipd_det
               exclusive-lock
               where ipd_part    = ecd4_part
               and   ipd_routing = ecd4_routing
               and   ipd_op      = ecd4_op
               and   ipd_test    = ecd4_sequence:

               /* DETERMINE IPD_DET START PCO# FROM QAD_WKFL   */
               /* QAD_CHARFLD[1] IS IPD_START_PCO VALUE        */
               for first qad_wkfl
                  fields(qad_charfld qad_key1 qad_key2 qad_key3)
                  where qad_key1 = "IPD-PCO-DATA"
                  and   qad_key2 = (ipd_part + '::' + ipd_routing + '::' +
                                    string(ipd_op) + '::' + ipd_test + '::' +
                                    if ipd_start <> ?
                                    then
                                       string(ipd_start)
                                    else
                                       "")
                  no-lock:
               end. /* FOR FIRST qad_wkfl */
               if available qad_wkfl
               and qad_charfld[1] = ecm_nbr
               then
                  delete ipd_det.
            end. /* FOR EACH ipd_det */

            /* RESET END DATE ON ORIGINAL RECORD */
            for each ipd_det
               exclusive-lock
               where ipd_part    = ecd4_part
               and   ipd_routing = ecd4_routing
               and   ipd_op      = ecd4_op
               and   ipd_test    = ecd4_sequence
               by ipd_start descending:

               /* DETERMINE IPD_START_PCO FROM QAD_WKFL        */
               /* QAD_CHARFLD[2] IS IPD_DET END PCO# VALUE     */
               for first qad_wkfl
                  fields(qad_charfld qad_key1 qad_key2 qad_key3)
                  where qad_key1 = "IPD-PCO-DATA"
                  and   qad_key2 = (ipd_part + '::' + ipd_routing + '::' +
                                    string(ipd_op) + '::' + ipd_test + '::' +
                                    if ipd_start <> ?
                                    then
                                       string(ipd_start)
                                    else
                                       "")
                  no-lock:
               end. /* FOR FIRST qad_wkfl */

               if available qad_wkfl
               and qad_charfld[2] = ecm_nbr
               then do:

                  for first ipddet
                     fields(ipd_end ipd_op ipd_part
                            ipd_routing ipd_start ipd_test)
                     where ipddet.ipd_part    = ipd_det.ipd_part
                     and   ipddet.ipd_routing = ipd_det.ipd_routing
                     and   ipddet.ipd_op      = ipd_det.ipd_op
                     and   ipddet.ipd_test    = ipd_det.ipd_test
                     and  (ipddet.ipd_start   > ipd_det.ipd_start
                     and   ipddet.ipd_start  <> ?)
                     no-lock:
                  end. /* FOR FIRST ipddet */

                  if available ipddet
                  then
                     ipd_det.ipd_end = ipddet.ipd_start - 1.
                  else
                     ipd_det.ipd_end = ?.

                  find first ipddet
                     where ipddet.ipd_part  = ipd_det.ipd_part
                     and ipddet.ipd_routing = ipd_det.ipd_routing
                     and ipddet.ipd_op      = ipd_det.ipd_op
                     and ipddet.ipd_test    = ipd_det.ipd_test
                     and (ipddet.ipd_start  < ipd_det.ipd_start
                          or ipddet.ipd_start  = ?)
                     exclusive-lock
                     no-error.

                  if available ipddet
                  and (ipddet.ipd_end = ?
                  or   ipddet.ipd_end >= ipd_det.ipd_start)
                  then do:
                     ipddet.ipd_end = ipd_det.ipd_start - 1.
                  end. /* IF AVAILABLE ipddet */

                  /* UPDATE IPD-PCO-DATA  STORED IN QAD_WKFL */
                  find qad_wkfl
                     exclusive-lock
                     where qad_key1 = "IPD-PCO-DATA"
                     and qad_key2 = (ipd_det.ipd_part + '::' +
                                     ipd_det.ipd_routing + '::' +
                                     string(ipd_det.ipd_op) + '::' +
                                     ipd_det.ipd_test + '::' +
                                     if ipd_det.ipd_start <> ?
                                     then
                                        string(ipd_det.ipd_start)
                                     else
                                        "")
                     no-error.

                  if not available qad_wkfl
                  then do:
                     create qad_wkfl.
                     assign
                        qad_key1 = "IPD-PCO-DATA".
                        qad_key2 = (ipd_det.ipd_part + '::' +
                                    ipd_det.ipd_routing + '::' +
                                    string(ipd_det.ipd_op) + '::' +
                                    ipd_det.ipd_test + '::' +
                                    if ipd_det.ipd_start <> ?
                                    then
                                       string(ipd_det.ipd_start)
                                    else
                                       "").
                  end.  /* IF NOT AVAILABLE... */

                  qad_charfld[2] = "".
               end.   /* IF AVAILABLE qad_wkfl... */
            end.   /* FOR EACH ipd_det.... */

            err_msg = 0.

            if last-of(ecd4_routing)
            then do:
               /* UNDO OF ITEM SPECIFICATION COMPLETE ITEM # ROUTING # */
               {pxmsg.i &MSGNUM=3734 &ERRORLEVEL=1 &MSGBUFFER=msg
                        &MSGARG1=ecd4_part
                        &MSGARG2=ecd4_routing}
               display stream prt
                  msg
                  with frame b STREAM-IO /*GUI*/ .
               down stream prt with frame b.
            end.  /* IF LAST-OF(ecd4_routing)... */
         end. /* FOR EACH ecd4_det */

         /* IF ERROR DETECTED IN ECD4_LOOP, ISSUE MESSAGE AND BYPASS */
         if err_msg <> 0
         then
            undo begin-changes, leave begin-changes.
      end.  /* DO (begin-changes) */
      /* IF NO ERRORS FOUND UPDATE MRP FLAGS, SET EFFECTIVE DATE  */
      /* AND PRINT INCORPORATION COMPLETE MESSAGE                 */
      if err_msg = 0
      then do:

         for each wk-table
            exclusive-lock
            use-index wk-par:

            for first pt_mstr
               fields(pt_bom_code pt_part pt_pm_code)
               where pt_part   = wk-par
               and pt_bom_code = ""
               and pt_pm_code <> "P"
               and pt_pm_code <> "D"
               no-lock:
            end. /* FOR FIRST pt_mstr */

            if available pt_mstr
            then do:
               for each in_mstr
                  exclusive-lock
                  where in_part = pt_part
                  and not can-find(ptp_det where ptp_part = in_part
                                             and ptp_site = in_site):
                  in_mrp = yes.
               end.  /* FOR EACH in_mstr... */
            end. /* IF AVAILABLE pt_mstr... */

            for each pt_mstr
               fields(pt_bom_code pt_part pt_pm_code)
               where pt_bom_code = wk-par
               and   pt_pm_code <> "P"
               and   pt_pm_code <> "D"
               no-lock:
               for each in_mstr exclusive-lock
                  where in_part = pt_part
                  and not can-find(ptp_det where ptp_part = in_part
                                             and ptp_site = in_site):
                  in_mrp = yes.
               end. /* FOR EACH in_mstr... */
            end. /* FOR EACH pt_mstr... */

            for each ptp_det
               fields(ptp_bom_code ptp_part ptp_pm_code ptp_site)
               where ptp_part     = wk-par
               and   ptp_bom_code = ""
               and   ptp_pm_code <> "P"
               and   ptp_pm_code <> "D"
               no-lock:
               find in_mstr
                  where in_part = ptp_part
                  and   in_site = ptp_site
                  exclusive-lock
                  no-error.
               if available in_mstr
               then
                  in_mrp = yes.
            end.  /* FOR EACH ptp_det... */

            for each ptp_det
               fields(ptp_bom_code ptp_part ptp_pm_code ptp_site)
               where ptp_bom_code = wk-par
               and   ptp_pm_code  <> "P"
               and   ptp_pm_code  <> "D"
               no-lock:
               find in_mstr
                  where in_part = ptp_part
                  and   in_site = ptp_site
                  exclusive-lock
                  no-error.
               if available in_mstr
               then
                  in_mrp = yes.
            end. /* FOR EACH ptp_det... */

            delete wk-table.

         end. /* FOR EACH wk-table... */

         /* UNINCORPORATION COMPLETE */
         {pxmsg.i &MSGNUM=3735 &ERRORLEVEL=1 &MSGBUFFER=msg}

         display stream prt
            msg WITH STREAM-IO /*GUI*/ .
         down stream prt 2 with frame b.

         find ecm2
            where recid(ecm2) = recid(ecm_mstr)
            exclusive-lock.
            ecm2.ecm_eff_date = ?.
         if ecm2.ecm_selected_eff = low_date
         then
            ecm2.ecm_selected_eff = ?.
      end. /* IF err_msg = 0... */

      /* IF ERRORS FOUND PRINT INCORP UNSUCCESSFUL MESSAGE AND END PROGRAM */
      else do:
         /* UNINCORPORATION UNSUCCESSFUL */
         {pxmsg.i &MSGNUM=3736 &ERRORLEVEL=1 &MSGBUFFER=msg}

         display stream prt
            msg WITH STREAM-IO /*GUI*/ .
         down stream prt with frame b.

         /* PROCESS ABORTED */
         {pxmsg.i &MSGNUM=3737 &ERRORLEVEL=1 &MSGBUFFER=msg}

         display stream prt
            "**" + msg + "**" @ msg WITH STREAM-IO /*GUI*/ .
         down stream prt 2 with frame b.

         undo mainloop.
         return.
      end.  /* err_msg <> 0 */
      err_msg = 0.
   end. /* MAINLOOP (for each ecm_mstr...) */

   if prt_page
   then do:
      hide frame b.
      page stream prt.
   end. /* IF prt_page... */

   {gprun.i ""ecincpr1.p""}

   
/*GUI*/ {mfguichk.i  &stream="(prt)"} /*Replace mfrpchk*/


   /* REPORT TRAILER */
   {mfrtrail.i "stream prt" "(prt)"}

end. /* REPEAT */
